﻿@namespace CodeManDesktopBlazor.BlazorComponents.Pages

@page "/CodeGens"

<Block Title="代码生成器" Introduction="基本字段生成">
    <div class="border split-demo" style="@FixedHeaderStyleName">
        <Split Basis="30%">
            <FirstPaneTemplate>
                <Split IsVertical="true" Basis="32%">
                    <FirstPaneTemplate>
                        <Card>
                            <CardBody>
                                <Block Title="字体类生成,输入字段,多个逗号分开：a,b,c" Introduction="上边面板">
                                    <div class="form-inline">
                                        <div class="row">

                                            <div class="form-group col-12 col-width @(isLoadDB?"hidden":"show")">
                                                <BootstrapInput PlaceHolder="@Localizer["Namespace"]" @bind-Value="@Model.classGenDTO.Namespace" DisplayText="@Localizer["Namespace"]" />
                                            </div>
                                            <div class="form-group col-12 col-width  @(isLoadDB?"show":"hidden")">
                                                <BootstrapInput PlaceHolder="@Localizer["Namespace"]" @bind-Value="@DbNameSpace" DisplayText="@Localizer["Namespace"]" />
                                            </div>
                                            <div class="form-group col-12 col-sm-6">
                                                <BootstrapInput PlaceHolder="@Localizer["Name"]" @bind-Value="@Model.classGenDTO.Name" DisplayText="@Localizer["Name"]" />
                                            </div>
                                            <div class="form-group col-12 col-sm-6">
                                                <Select Color="Color.Primary" OnSelectedItemChanged="@OnSelectedItemChanged" @bind-Value="@Model.classGenDTO.Type"></Select>
                                            </div>
                                            <div class="form-group col-12 col-width">
                                                <Textarea rows="3" @bind-Value="@Model.InputContent" DisplayText="@Localizer["InputContent"]" />
                                            </div>
                                            <div class="form-group col-12 col-sm-3">
                                                <Button @onclick="@GenCodeClick" Color="Color.Primary">生成</Button>
                                            </div>
                                            <div class="form-group col-12 col-sm-4">
                                                <button @onclick="@GenCopyClick" class="btn btn-primary @(!copyIsDisabled?"disabled":"active")" >复制到本地</button>
                                            </div>
                                            <div class="form-group col-12 col-sm-3">
                                                <Button @onclick="@ReflashClick" Color="Color.Info">刷新</Button>
                                            </div>
                                        </div>
                                    </div>
                                </Block>
                            </CardBody>
                        </Card>
                    </FirstPaneTemplate>
                    <SecondPaneTemplate>
                        <div id="divTreeData" style="min-width:@($"{Width*0.3}px");min-height:@($"{Height*0.63}px");" class="div-tree">
                            <div class="row">
                                <div class="form-group col-12 col-width">
                                    <input class="form-control" type="text" @oninput="@OnSelectedSearchItemChanged" placeholder="筛选" />
                                </div>
                            </div>
                            <Scroll Height="@($"{Height*0.60}px")">
                                <Tree ClickToggleNode="true" OnExpandNode="OnExpandNode" Items="@CheckedItems" OnTreeItemChecked="@OnTreeItemChecked" ShowCheckbox="true" ShowIcon="true" class="tree-data" />
                            </Scroll>
                        </div>
                    </SecondPaneTemplate>
                </Split>
            </FirstPaneTemplate>
            <SecondPaneTemplate>
                <Tab IsBorderCard="true" @ref="TabSet">
                    <TabItem Text="C#" Icon="fa fa-file-code-o">
                        <Scroll Height="@($"{Height-100}px")" Width="@($"{Width*0.66}px")">

                            <div class="pre-code" ref="PreElement">
                                <Button @onclick="@(e=>CopyToClipboard("divClassDemoTemple"))" Color="Color.Primary" class="btn-clipboard" data-toggle="tooltip" title="@CopyToClipboardString">Copy</Button>
                                <div id="divClassDemoTemple" style="min-width:@($"{Width*0.66}px");min-height:@($"{Height-200}px");">
                                    @switch (Model.classGenDTO.Type)
                            {
                                    case ClassTypeEnum.Entity:
                                        <ClassEntityTemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                @a.AName
                                            </AttrTemplate>
                                        </ClassEntityTemple>
                                        break;
                                    case ClassTypeEnum.EntityDTO:
                                        <ClassEntityDTOTemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                @a.AName
                                            </AttrTemplate>
                                        </ClassEntityDTOTemple>
                                        break;
                                    case ClassTypeEnum.EntityDB:
                                        <ClassEntityDBTemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                @a.AName
                                            </AttrTemplate>
                                        </ClassEntityDBTemple>
                                        break;
                                    case ClassTypeEnum.EntityMvvMDB:
                                        <ClassEntityDBMVVMTemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                 @a.AName
                                            </AttrTemplate>
                                        </ClassEntityDBMVVMTemple>
                                        break;
                                    case ClassTypeEnum.EntityICEDB:
                                        <ClassEntityDBICETemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                 @a.AName
                                            </AttrTemplate>
                                        </ClassEntityDBICETemple>
                                        break;
										
                                    case ClassTypeEnum.EntityNotifyBaseDB:
                                        <ClassEntityDBNotifyBaseTemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                 @a.AName
                                            </AttrTemplate>
                                        </ClassEntityDBNotifyBaseTemple>
                                        break;
                                    default:
                                        <EntityDTOUITemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                            <AttrTemplate>
                                                @a.AName
                                            </AttrTemplate>
                                        </EntityDTOUITemple>
                                        break;
                            }
                                </div>
                            </div>

                        </Scroll>
                    </TabItem>
                    <TabItem Text="多语言" Icon="fa fa-html5">
                        <Scroll Height="@($"{Height-100}px")" Width="@($"{Width*0.66}px")">
                            <div class="pre-code">
                                <Button @onclick="@(e=>CopyToClipboard("divMulLangageTemple"))" Color="Color.Primary" class="btn-clipboard" data-toggle="tooltip" title="@CopyToClipboardString">Copy</Button>
                                <div id="divMulLangageTemple" style="min-width:@($"{Width*0.66}px");min-height:@($"{Height-200}px");">
                                    <MulLangageTemple K="ClassGenDTOCreateUpdate" T="ClassAttributeDTO" Model="Model" Context="a">
                                        <AttrTemplate>
                                            @a.AName
                                        </AttrTemplate>
                                    </MulLangageTemple>
                                </div>
                            </div>
                        </Scroll>
                    </TabItem>
                </Tab>

            </SecondPaneTemplate>
        </Split>
    </div>
</Block>
<Toast @ref="Toast"></Toast>
